package com.atguigu.educenter.controller;

import com.atguigu.commonutils.R;
import com.atguigu.commonutils.vo.commentVo.CommentMemberVo;
import com.atguigu.educenter.service.IUcenterMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @create: 2022/10/11
 * @Description:
 * @FileName: UcenterBackEndController
 * @自定义内容：
 */
@RestController
@RequestMapping("/educenter/BackEnd")
public class UcenterBackEndController {

    @Autowired
    private IUcenterMemberService iUcenterMemberService;

    //根据token获取用户信息
    @GetMapping("getMemberInfo/{memberId}")
    public CommentMemberVo getMemberInfo(@PathVariable String memberId){
        //调用jwt工具类的方法。根据request对象获取头信息，返回用户id
        CommentMemberVo memberVo = iUcenterMemberService.getCommentUserInfo(memberId);
        return memberVo;
    }

    //查询某一天的注册人数
    @GetMapping("countRegister/{day}")
    public R countRegister(@PathVariable String day){
        Integer count = iUcenterMemberService.countRegisterDay(day);
        return R.ok().data("countRegister",count);
    }
}
